package web.handle;

import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

import ejb.entity.Position;
import ejb.entity.User;
import ejb.manager.PositionManager;
import ejb.manager.UserManager;

@ManagedBean
public class UserPositionBean {
	@EJB
	private PositionManager pm;
	@EJB
	private UserManager um;
	
	private List<Position> positions;

	public UserPositionBean(){}
	
	private void setListPositions(){
		String login = FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();
		User currentuser = um.getUserByLogin(login);
		setPositions(pm.getUserPositions(currentuser));
	}
	
	public List<Position> getPositions() {
		this.setListPositions();
		return positions;
	}

	public void setPositions(List<Position> positions) {
		this.positions = positions;
	}
	
	
}
